cmake_minimum_required(VERSION 3.0.2)
project(global_path_planner)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  cln_msgs
  tf
  common_osqp
  common_statistics
  common_planning
)

find_package(Eigen3 REQUIRED)
find_package(OpenCV  REQUIRED COMPONENTS)
find_package(CGAL QUIET COMPONENTS Core)
find_package(PkgConfig REQUIRED)

pkg_check_modules(YAMLCPP yaml-cpp REQUIRED)
if(YAMLCPP_VERSION VERSION_GREATER "0.5.0")
    add_definitions(-DHAVE_YAMLCPP_GT_0_5_0)
endif()

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME}
  CATKIN_DEPENDS roscpp common_osqp common_statistics common_planning
#  DEPENDS system_lib
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${EIGEN_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${CGAL_INCLUDE_DIRS}
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_SOURCE_DIR}/common
)

file(GLOB_RECURSE srcs "src/*.cc" "src/*.cpp")
file(GLOB_RECURSE hdrs "include/*.h")
add_executable(${PROJECT_NAME}_node ${srcs} ${hdrs})
add_executable(test_${PROJECT_NAME}_node test/test_global_path_planner.cpp)

add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(test_${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(${PROJECT_NAME}_node
  ${catkin_LIBRARIES}
  ${OpenCV_LIBS}
  CGAL::CGAL
  CGAL::CGAL_Core
  ${YAMLCPP_LIBRARIES}
  glog
  osqp
)

target_link_libraries(test_${PROJECT_NAME}_node
  ${catkin_LIBRARIES}
  glog
  osqp
)